import { request } from '../request';

interface dictItem {

    itemText: string;
    itemValue: string;
}


// interface Dict {
//     records: Array<any>
// }


export async function getDict(dictCode: String) {
    const { error, success } = await request.get<any>(`/sys/dict/list?dictCode=${dictCode}`, {}, {
        useErrMsg: true
    });
    const id = success?.records[0]?.id

    if (!error && id) {
        const { error, success } = await request.get<any>(`/sys/dictItem/list?dictId=${id}`, {
            pageSize: 100
        }, {
            useErrMsg: true
        });

        if (!error && success?.records) return success?.records as Array<dictItem>
    }
}

